<br>
<div class="panel panel-default shadowed">
    <div class="panel-heading clearfix">
        <h2 class="panel-title pull-left">Orders</h2>
        <div class="pull-right">
            <form class="form">
                <input type="text" class="form-control" ng-model="oc.searchOrder" placeholder="Search...">
            </form>
        </div>
        <div class="pull-right" ng-show="oc.isSalesman()">
            <button type="button" class="btn btn-primary" ng-click="oc.editOrder(undefined)"><span class="fa fa-plus"></span> Order</button>
        </div>
        <div class="pull-right">
            <form class="form">
                <input type="checkbox" ng-model="oc.showAll"> Show all &nbsp;
            </form>
        </div>
    </div>
    <div class="panel-body">
        <table class="table table-hover table-mouse-hover">
            <thead>
            <tr>
                <th>Salesman</th>
                <th>Customer Name</th>
                <th>Open Date</th>
                <th>Status</th>
                <th>Status Date</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="order in oc.orders| filter: oc.searchOrder | filter: oc.filterOrders" ng-click="oc.editOrder(order)">
                <td>{{oc.getOrderSalesmanUsername(order)}}</td>
                <td>{{oc.getOrderCustomerName(order)}}</td>
                <td>{{order.open_date}}</td>
                <td>{{oc.getOrderStatus(order)}}</td>
                <td>{{order.status_date}}</td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script type="text/ng-template" id="editOrder">
    <div class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="editOrderLabel">Edit Order</h4>
                </div>
                <div class="modal-body">
                    <form role="form">
                        <div class="row">
                            <div class="form-group col-md-6">
                                <label for="customer-name">Customer Name</label>
                                <select class="form-control" ng-model="eoc.order.customer_id" id="customer-name" ng-options="customer.id as customer.name for customer in eoc.customers">
                                    <option style="display:none" value="">Select a Customer</option>
                                </select>
                            </div>
                            <div class="form-group col-md-4">
                                <label for="status">Status</label>
                                <input type="text" ng-model="eoc.orderStatus" id="status" class="form-control" ng-disabled="true">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning" data-dismiss="modal" ng-click="eoc.close('none')">
                        <span class="fa fa-close"></span> Cancel
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="eoc.close('update')" ng-show="eoc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Update Order
                    </button>
                    <button type="button" class="btn btn-success" data-dismiss="modal" ng-click="eoc.close('add')" ng-show="!eoc.isDeleteAllowed()">
                        <span class="fa fa-check"></span> Add Order
                    </button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="eoc.close('delete')" ng-show="eoc.isDeleteAllowed()">
                        <span class="fa fa-trash"></span> Delete Order
                    </button>
                </div>
            </div>
        </div>
    </div>
</script>
